l=['michael','search','tryact','bod','jack']
print(l[0:3])


d = {'a': 1, 'b': 2, 'c': 3}
for key in d:
	print(key)


# 列表生成器
u=list(range(1, 11))
for key in u:
	print(key)


L = ['Hello', 'World', "dadsa", 'Apple', 'None']
um=[s.lower() for s in L]
print(um)


# 生成器的使用
g = (x * x for x in range(10))
for n in g:
	print(n)


g = fib(5)
while 1:
    try:
        x = next(g)
        print('g:', x)
    except StopIteration as e:
        print('Generator return value:', e.value)
        break


s = (x * x for x in range(5))
print(s)
for x in s:
    print(x)

def fib(max):
    n, a, b = 0, 0, 1
    while n < max:
        yield b
        a, b = b, a + b
        n = n + 1
    return 'done'

f = fib(10)
print('fib(10):', f)
for x in f:
    print(x)